package com.lp.business.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.iframework.commons.domain.enums.RecordStatus;
import org.iframework.commons.domain.order.Order;
import org.iframework.commons.domain.pager.Pager;
import org.iframework.commons.util.fast.V;
import org.iframework.support.spring.hibernate.dao.BaseHibernateDaoSupport;
import org.iframework.support.spring.hibernate.service.BaseServiceSupport;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.lp.business.dao.CollectionDao;
import com.lp.business.model.Collection;
import com.lp.business.service.CollectionService;

/**
 * 收藏信息模型服务接口实现类<br>
 * 说明：支持方法查阅实现接口
 * 
 * @author lp
 * @email lp@qq.com
 * @date 2018-08-23 10:38:17
 */
@Service("collectionService")
public class CollectionServiceImpl extends BaseServiceSupport<Collection, String> implements CollectionService {
	@Resource(name = "collectionDao")
	public void setBaseHibernateDaoSupport(@Qualifier("collectionDaoImpl") BaseHibernateDaoSupport<Collection, String> baseHibernateDaoSupport) {
		this.baseHibernateDaoSupport = baseHibernateDaoSupport;
	}

	@Override
	public List<Map<String, Object>> findCollections(Collection model, Order order, Pager pager) {
		return ((CollectionDao)this.baseHibernateDaoSupport).findCollections(model, order, pager);
	}

	@Override
	public int isCollection(String memberId, String reportId) {
		if(V.isEmpty(memberId)||V.isEmpty(reportId)) {
			return 0;
		}
		Collection model = new Collection();
		model.setStatus(RecordStatus.AVAILABLE);
		model.setMemberId(memberId);
		model.setReportId(reportId);
		List<Collection> models = this.findByModel(model, null, null);
		return V.isNotEmpty(models)?1:0;
	}
}